﻿#region Copyright 
/*-------------------------------------------------------------------------
* 命名空间名称/文件名:    SSPivot.Tools/ServiceCollectionExtensions 
* CLR版本:     4.0.30319.42000
* 机器名称:    DESKTOP-NHMLO8A
* 功 能：       N/A
* 类 名：       ServiceCollectionExtensions
* 创建时间：  2025/5/23 17:11:36
* 版本号：      v1.0
* 创建人:        xulong
*-------------------------------------------------------------------------*/
#endregion 
using IP2Region.Net.Abstractions;
using IP2Region.Net.XDB;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SSPivot.Authorization.Authorize;
using SSPivot.Common.Helpers;
using SSPivot.Tools.Config;
using SSPivot.Tools.Services.FileUpload;
using SSPivot.Tools.Services.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSPivot.Tools
{
    public static class ServiceCollectionExtensions
    {
        public static void AddSSPivotTools(this IServiceCollection services,IConfiguration configuration)
        {
            services.AddSingleton<IEHelper>();
            var config = configuration.GetSection("IP2Region").Get<IP2RegionConfig>();// ConfigHelper.Get<Config.IP2RegionConfig>("IP2Region");
            //城市地区定位服务 
            if (config.Enabled)
            {
                services.AddSingleton<ISearcher>(new Searcher(CachePolicy.Content, Path.Combine(AppContext.BaseDirectory, "ip2region.xdb")));
            }
            //file upload
            var fileConfig = configuration.GetSection("FilesStorage").Get<FilesStorageConfig>();// ConfigHelper.Get<FilesStorageConfig>("FilesStorageConfig");
            services.AddSingleton<IFileUploadService, FileUploadService>();
            //tools
            services.AddSingleton<IToolService, ToolService>();

        }
    }
}
